<template>
    <div class="detail_container">
        <Banner title='产品详情' flag="product"></Banner>
        <div class="contaienr-fluid" style="background-color: #fff;">
            <div class="container breadcrumb_container">
                <el-breadcrumb separator-icon="ArrowRight">
                    <el-breadcrumb-item
                        :to="{ path: '/product', query: { tmId: product.tmId, page: page } }">产品中心</el-breadcrumb-item>
                    <el-breadcrumb-item>{{ product.name }}</el-breadcrumb-item>
                </el-breadcrumb>
                <a v-if="product.pdfLink" class="download" href="./wenyao.pdf" download="文鳐2.0版本软件管理.pdf"
                    target="_blank">文档下载</a>
            </div>
            <div class="container content">
                <div class="row">
                    <!-- 轮播图 -->
                    <div class="col-lg-12 wow animate__animated animate__fadeInUp" data-wow-duration="2s">
                        <el-carousel indicator-position="none" class="carousel_container" arrow="never">
                            <el-carousel-item v-for="item in product.imgArr" :key="item.id">
                                <div class="img_container">
                                    <img :src="item.imgUrl" alt="item.id">
                                </div>
                            </el-carousel-item>
                        </el-carousel>
                    </div>
                    <!-- 产品介绍 -->
                    <div class="col-lg-12 introduce wow animate__animated animate__fadeInUp" data-wow-duration="2s"
                        data-wow-delay="0.1s" v-if="product.introduce">
                        <h3>产品介绍</h3>
                        <p>{{ product.introduce }}</p>
                    </div>
                </div>
            </div>
        </div>
        <!-- 产品优势 -->
        <div class="container-fluid advantage wow animate__animated animate__fadeInUp" data-wow-duration="2s"
            v-if="product.advantageList">
            <h3>产品优势</h3>
            <div class="container advantage_content">
                <div class="advantage_item" v-for="item in product.advantageList" :key="item.id">
                    <div class="text">{{ item.text }}</div>
                    <div class="shape"></div>
                    <div class="english">{{ item.english }}</div>
                </div>
            </div>
        </div>
        <!-- 产品参数 -->
        <div class="container-fluid argument" v-if="product.argumentList">
            <div class="container wow animate__animated animate__fadeInUp" data-wow-duration="2s">
                <h3 class="text-center">产品参数</h3>
                <div class="row argument_row wow animate__animated animate__fadeInUp" data-wow-duration="2s"
                    v-for="(arr, index) in product.argumentList" :key="index">
                    <div class="col-lg-12 argument_item" v-for="item in arr" :key="item.id">
                        <div class="title">{{ item.title }}</div>
                        <div class="text_container">
                            <div class="text" v-for="i in item.content" :key="i.id">{{ i.text }}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { onMounted, computed, nextTick } from 'vue';
import { useRoute } from 'vue-router';
import useProductStore from '@/store/modules/product.ts'
import WOW from "wow.js";// 在vue3中下载的是wow.js|vue2中是wowjs

const productStore = useProductStore()
const route = useRoute()

let productId = computed(() => route.query.id) // 获取产品中心页携带过来的产品id
let product = computed(() => productStore.productInfo) // 通过计算数据获取仓库里的产品详情信息
let page = computed(() => productStore.page || 1) // 获取仓库里的当前选中页码 || 如果刷新详情页面再返回会丢失page数据此时默认是第一页

onMounted(() => {
    getProduct()
    //初始化wow.js(页面滚动加载动画)
    nextTick(() => {   //页面渲染完，在执行
        new WOW().init()
    })
})
// 获取产品信息
const getProduct = async () => {
    const id = Number(productId.value)
    await productStore.getProduct(id)
}
</script>

<style lang="scss" scoped>
.detail_container {
    background: url(./image/detail_bg.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed; // 固定背景图

    .breadcrumb_container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 70px;
        border-bottom: 1px solid #eeeeee;

        .el-breadcrumb__item {
            .is-link:hover {
                color: #4F68AC;
            }
        }

        .download {
            font-size: 14px;
            color: #4F68AC;
            font-weight: 550;
            user-select: none;
            cursor: pointer;
            text-decoration: none;
            transition-duration: 0.3s;
            transition: all 0.2s linear;

            &:hover {
                color: #304784;
            }

            &:active {
                transform: scale(0.9);
            }
        }
    }

    .content {
        margin-top: 24px;

        .carousel_container {
            height: 340px;
            background: linear-gradient(to bottom, #f5f5f5, #ffffff);

            .img_container {
                height: 100%;
                display: flex;
                justify-content: center;

                img {
                    width: 380px;
                }
            }
        }

        .introduce {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-between;
            margin-top: 80px;
            margin-bottom: 80px;

            h3 {
                font-size: 30px;
                color: #333;
                margin-bottom: 40px;
            }

            p {
                padding: 0 12px;
                font-size: 16px;
                color: #666;
                text-align: center;
                line-height: 28px;
            }
        }
    }

    .advantage {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        height: 100%;
        padding: 80px 0px 80px;

        h3 {
            font-size: 30px;
            color: #333;
            margin-bottom: 50px;
        }

        .advantage_content {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: space-around;

            .advantage_item {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                background-color: #fff;
                border: 1px solid #eee;
                padding: 24px 0;
                margin-bottom: 24px;
                cursor: pointer;
                transition: all 0.2s linear;

                &:hover {
                    box-shadow: 1px 10px 34px 1px rgb(0 0 0 / 10%);
                    transform: translateY(-3px);
                }

                .text {
                    font-size: 20px;
                }

                .shape {
                    width: 100px;
                    height: 5px;
                    border-radius: 10px;
                    background: linear-gradient(to right, rgba(79, 104, 172, 0), rgba(79, 104, 172));
                    margin: 12px 0px 12px;
                }

                .english {
                    font-size: 20px;
                    font-weight: bold;
                    color: #E7EBF2;
                }

            }
        }
    }

    .argument {
        width: 100%;
        background-color: #fff;
        padding: 60px 0 120px;

        h3 {
            font-size: 30px;
            color: #333;
            margin-bottom: 50px;
        }

        .argument_row {
            margin-bottom: 40px;

            .argument_item {
                display: flex;
                flex-direction: row;
                flex-wrap: nowrap;
                font-size: 15px;
                margin-bottom: 1px;

                .title {
                    flex: 1;
                    background-color: #4F68AC;
                    color: #fff;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    margin-right: 2px;
                    padding: 12px;
                    text-align: center;
                    font-weight: 550;
                    letter-spacing: 1px;
                    font-size: 14px;
                }

                .text_container {
                    flex: 3;
                    background-color: #f5f5f5;
                    display: flex;
                    flex-direction: row;
                    flex-wrap: nowrap;

                    .text {
                        height: 100%;
                        width: 100%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        border-right: 2px solid #fff;
                        color: #444;
                        padding: 12px;
                        text-align: center;
                        font-size: 16px;
                    }
                }
            }
        }
    }
}

/* 设置响应式 */
/* 手机端 */
@media (max-width: 992px) {
    .advantage_item {
        width: 100%;
    }
}

/* 除了手机端 */
@media (min-width: 992px) {
    .advantage_item {
        width: 350px;
    }
}
</style>
<style>
/* 面包屑样式 */
.el-breadcrumb__item {
    .is-link {
        transition-duration: 0.3s;

        &:hover {
            color: #4f68ac;
        }
    }
}
</style>